package com.hengdu.cms.workquene;

import java.io.IOException;

import com.hengdu.cms.util.RabbitMQUtils;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.DefaultConsumer;
import com.rabbitmq.client.Envelope;
import com.rabbitmq.client.AMQP.BasicProperties;

public class Customer2 {

	public static void main(String[] args) throws IOException {

		Connection connection = RabbitMQUtils.getConnection();
		Channel channel = connection.createChannel();
		channel.basicQos(1);

		channel.queueDeclare("wordk", true, false, false, null);
		channel.basicConsume("work", true, new DefaultConsumer(channel) {
			@Override
			public void handleDelivery(String consumerTag, Envelope envelope, BasicProperties properties, byte[] body) throws IOException {

				System.out.println("消费者 2 :" + new String(body));
				channel.basicAck(envelope.getDeliveryTag(), false);
			}
		});

	}
}
